package com.zbkc.util;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.Application;

public class MyApplication extends Application {

	private static MyApplication instance;
	private List<Activity> activityList;
	private List<Activity> activityTabList;

	public static MyApplication getInstance() {
		return instance;
	}

	public void addActivity(Activity paramActivity) {
		this.activityList.add(paramActivity);
	}

	public void addTabActivity(Activity paramActivity) {
		this.activityTabList.add(paramActivity);
	}

//	public void exit() {
//		Process.killProcess(Process.myPid());
//	}

	public void exitTabActivity() {
		for (int i = 0;; i++) {
			if (i >= this.activityTabList.size())
				return;
			Activity localActivity = (Activity) this.activityTabList.get(i);
			LogUtil.e("被干掉的Activity:" + localActivity.getClass().getName());
			localActivity.finish();
		}
	}

	public void finishAllActivity() {
		for (int i = 0;; i++) {
			if (i >= this.activityList.size())
				return;
			Activity localActivity = (Activity) this.activityList.get(i);
			LogUtil.e("被干掉的Activity:" + localActivity.getClass().getName());
			localActivity.finish();
		}
	}

	public void onCreate() {
		super.onCreate();
		instance = this;
		this.activityList = new ArrayList();
		this.activityTabList = new ArrayList();
	}

	public void removeActivity(Activity paramActivity) {
		paramActivity.finish();
	}

}
